import React from "react";

class MyRefComponent extends React.Component<any, any> {



    input1 = React.createRef<HTMLInputElement>();
    input2: HTMLInputElement | null = null;

    handler = () => {
        console.log(this.input1.current?.value)
    }

    value2Change = (e: any) => {
        console.log(this.input2?.value)
    }

    render() {
        return (
            <>
                <input ref={this.input1} placeholder={'输入数据'} />
                <input type={'button'} value={'点击弹出输入数据'} onClick={this.handler}/>
                <input ref={(e) => {
                    console.log(1)
                    this.input2 = e
                }} placeholder={'输入数据'} onBlur={this.value2Change}/>
            </>
        )
    }
}

export default MyRefComponent